name: build
on: [pull_request, push]
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.7]
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
          cache-dependency-path: setup.py
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e '.[MongoTrials, SparkTrials, ATPE, dev]'
          pip install pyspark
      - name: Test with pytest - Unit tests
        run: |
          python -m pytest ./hyperopt/tests/unit
      - name: Test spark plugin - pin thread mode
        run: |
          PYSPARK_PIN_THREAD=true pytest hyperopt/tests/integration/test_spark.py
      - name: Test spark plugin - non pin thread mode
        run: |
          PYSPARK_PIN_THREAD=false pytest hyperopt/tests/integration/test_spark.py
